import random

import pandas as pd

# 读取Excel文件
data = pd.read_excel('data.xls', header=None, skiprows=1)

# 获取文件行数
total_rows = len(data)

# 随机抽样30行
sampled_rows = random.sample(range(0, total_rows), 30)
sampled_rows.sort()

# 打开输出文件
with open('output.md', 'w', encoding='utf-8') as output_file:
    # 遍历抽样的行数
    for row_index in sampled_rows:
        row = data.iloc[row_index]
        output_file.write("+ 在" + row[0] + '中，注释为：`' + row[2] + '`\n')
        output_file.write("```java\n" + row[1] + "\n```\n\n")